package com.touna.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * author: xl
 * time: 2018/6/19 11:55
 * description:正则表达式
 **/
public class RegexGroupTest {

    public static void main(String[] args) {
        String regEx = "\\w+\\[(\\d+)]$";
        String s = "Res_Loan_Mode[47]";
        Pattern pat = Pattern.compile(regEx);
        Matcher mat = pat.matcher(s);
        if(mat.find()){
            System.out.println(mat.group(0));
            System.out.println(mat.group(1));
        }
        String regEx2 = "(\\w+)(\\[)";
        Pattern pat2 = Pattern.compile(regEx2);
        Matcher mat2 = pat2.matcher(s);
        if(mat2.find()){
            System.out.println(mat2.group(0));
            System.out.println(mat2.group(1));
        }
    }



}
